<?php 
session_start();
class report extends CI_Controller  {

        /**
        * Index Page for this controller.
        *
        * Maps to the following URL
        * 		http://example.com/index.php/welcome
        *	- or -  
        * 		http://example.com/index.php/welcome/index
        *	- or -
        * Since this controller is set as the default controller in 
        * config/routes.php, it's displayed at http://example.com/
        *
        * So any other public methods not prefixed with an underscore will
        * map to /index.php/welcome/<method_name>
        * @see http://codeigniter.com/user_guide/general/urls.html
        */
       private $_configs = null;
       function __construct()
        {
            parent::__construct();
            $this->load->helper('url');
            $this->load->library('smarty3');
            $this->load->model('colmod/report_colmod');
            $this->load->model('APanel/report_model');
            include APPPATH . 'libraries/defu.php';
            
            $this->colModel=new report_colmod();
            $this->smarty=new CI_Smarty3();$this->smarty->error_reporting = E_ALL & ~E_NOTICE;
            $this->report_model=new report_model();
            
        }
        public function index()
	{
            
        }
        public function product()
	{
            //unset($_SESSION["ADP"][CCTRL."-JQX"]["colModel"]);
            if(!checkAuthority("report")){
                $this->smarty
                        ->assign('_SESSION', $_SESSION)
                        ->display("sys/04_access_denied");
                return;
            }
            $colModel=$this->colModel->get();
            $Data["colModel"]=$colModel;
            $this->smarty
                    ->assign('_SESSION', $_SESSION)
                    ->assign('Data', $Data)
                    ->display("APanel/report/product");
	}
        function jqgrid_data(){
            $colModel=$this->colModel->get();
            //$Categorys=$this->category_model->gets();
            //$Regions=$this->region_model->getByParent();
            $aData=array();
            $result['total_rows']=0;
            //if($this->checkauthority()>=0){
                $result=$this->report_model->binding();
                $rows=$result['rows'];
                // get data and store in a json array
                foreach ($rows as $row) {
                    $cel=array();
                    foreach ($colModel as $col){
                        $f=$col["datafield"];
                        $cel[$f]=$row->$f;
                    }
                    $aData[] = $cel;
                }
            
            $data[] = array(
                'TotalRows' => $result['total_rows'],
                'Rows' => $aData
            );
            echo json_encode($data);
        }
        
        
        
        
       
        
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */